package com.sat.goods.service.impl;

import com.sat.goods.dao.CategoryMapper;
import com.sat.goods.pojo.Brand;
import com.sat.goods.pojo.Category;
import com.sat.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> findByParentId(Integer pid) {

        //创建条件对象
        Example example = new Example(Category.class);
        Example.Criteria criteria = example.createCriteria();
        //构造条件
        criteria.andEqualTo("parentId",pid);

        //根据条件查询
        List<Category> categories = categoryMapper.selectByExample(example);
        return categories;
    }


}
